package com.bootdo.xiao.suggest;

/**
 * @Auther: liuj
 * @Date: 2019/6/17 15:07
 * @Description:建议34：构造函数尽量简化（赋予构造函数复杂的逻辑会影响）
 */
public class Suggest34 {
    public static void main(String[] args){
        Server server = new client(1000);
        //调用说明
    }
}

abstract class Server{
    public static final int DEFAULT_PORT = 4000;

    public Server(){
        int port = getPort();
        System.out.println(port);
    }

    protected abstract int getPort();
}

class client extends Server{
    public int port = 100;

    public client(int _port){
        super();
        port = _port;
    }

    @Override
    protected int getPort() {
        return Math.random() > 0.5 ? port : DEFAULT_PORT;
    }
}
